package cn.yr.oauth.configuration;

import cn.yr.oauth.properties.QQProperties;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.request.AuthQqRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(QQProperties.class)
@ConditionalOnProperty(
        prefix = "oauth.qq",
        name = "appKey"
)
public class QQConfiguration {

    @Autowired
    private QQProperties qqProperties;

    @Bean
    public AuthQqRequest getAuthQqRequest(){
        return new AuthQqRequest(AuthConfig.builder()
                .clientId(qqProperties.getAppKey())
                .clientSecret(qqProperties.getAppSecret())
                .redirectUri(qqProperties.getRedirectUrl())
                .build());
    }
}
